import Vue from 'vue';
import Abstract from './pages/common/abstract';
import NotFound from './pages/common/404';

// list with filters page
import ShopList from './pages/shop/shop';
import ProductList from './pages/product/product';
import IndentList from './pages/indent/indent';
import BannerList from './pages/banner/banner';
import ScenicList from './pages/scenic/scenic';
import Login from './pages/login/login';
import chart from './pages/chart/chart';
import Guide from './pages/guide/guide';

const root = Vue.component('root', {
  template: '<router-view></router-view>'
});

let routes = [
  {
    path: '/login',
    component: Login,
    name: 'login',
    meta: {
      hidden: true
    }
  },
  {
    path: '/404',
    component: NotFound,
    name: '404',
    meta: {
      requiresAuth: true
    }
  },
  {
    path: '/',
    component: root,
    meta: {
      requiresAuth: true
    },
    children: [
      {
        path: 'list',
        component: Abstract,
        name: '店铺与产品',
        iconClass: 'el-icon-message',
        children: [
          {
            path: 'shop',
            name: '店铺管理',
            component: ShopList,
            imgUrl: 'https://o0p2g4ul8.qnssl.com/vsite%2Fbackground.jpg'
          },
          {
            path: 'product',
            name: '产品管理',
            component: ProductList,
            imgUrl: 'https://o0p2g4ul8.qnssl.com/vsite%2Fbackground.jpg'
          },
          {
            path: 'indent',
            name: '订单管理',
            component: IndentList,
            imgUrl: 'https://o0p2g4ul8.qnssl.com/vsite%2Fbackground.jpg'
          }
        ]
      },
      {
        path: 'user',
        component: Abstract,
        name: '用户管理',
        iconClass: 'el-icon-setting',
        children: [
          {
            path: 'guide',
            name: '导游管理',
            component: Guide,
            imgUrl: 'https://o0p2g4ul8.qnssl.com/vsite%2Fbackground.jpg'
          }
        ]
      },
      {
        path: 'form',
        component: Abstract,
        name: 'banner与十景',
        iconClass: 'el-icon-document',
        children: [
          {
            path: 'banner',
            name: 'banner管理',
            component: BannerList,
            imgUrl: 'https://o0p2g4ul8.qnssl.com/vsite%2Fbackground.jpg'
          },
          {
            path: 'scenic',
            name: '十景管理',
            component: ScenicList,
            imgUrl: 'https://o0p2g4ul8.qnssl.com/vsite%2Fbackground.jpg'
          }
        ]
      }
    ]
  },
  {
    path: '*',
    redirect: {path: '/404'}
  }
];
let menuCount = routes.length;
routes[menuCount - 2].children.forEach(route => {
  if (route.children) {
    if (!route.meta) route.meta = {};
    route.meta.children = route.children;
  }
});

export default routes;
